package com.example.nyf.common;

import java.util.HashMap;

public class AjaxResult extends HashMap<String, Object> {

    private static final String CODE = "code";
    private static final String MSG = "msg";
    private static final String DATA = "data";

    public AjaxResult(Boolean code, String msg) {
        super.put(CODE, code);
        super.put(MSG, msg);
    }

    public AjaxResult(Boolean code, String msg, Object data) {
        super.put(CODE, code);
        super.put(MSG, msg);
        super.put(DATA, data);
    }

    public static AjaxResult success() {
        return new AjaxResult(true, "操作成功");
    }

    public static AjaxResult success(String msg) {
        return new AjaxResult(true, msg);
    }

    public static AjaxResult success(String msg, Object data) {
        return new AjaxResult(true, msg, data);
    }

    public static AjaxResult error() {
        return new AjaxResult(false, "失败");
    }

    public static AjaxResult error(String msg) {
        return new AjaxResult(false, msg);
    }
}
